package common;

public class Node {

	public int x;
	public int y;
	
	public Node north;
	public Node south;
	public Node east;
	public Node west;
	
	
	public Node(int x, int y){
		this.x = x;
		this.y = y;
	}
	
	public void setAdjacentNodes(Node n, Node s, Node e, Node w){
		north = n;
		south = s;
		east = e;
		west = w;
	}
	
	public boolean isAdjacent(Node n){
		return (north!=null && north.equals(n)) || (south!=null && south.equals(n)) || (east!=null && east.equals(n)) || (west!=null && west.equals(n));
		
	}
	
	public boolean equals(Node n){
		return this.x == n.x && this.y == n.y;
	}
	
	public String toString(){
		return "Node(" + x + ";" + y + ")";
	}
}
